<template>
	<view class="container">
		<uni-forms ref="form" :value="formData" validate-trigger="submit" err-show-type="toast">
					<uni-forms-item name="createTime" label="测量时间">
						<uni-easyinput v-model="formData.createTime" disabled="true"></uni-easyinput>
					</uni-forms-item>
		            <uni-forms-item name="bodyStatus" label="身体状态">
		                <uni-data-select placeholder="请选择身体状态" v-model="formData.bodyStatus" :localdata="formOptions.bodyStatus">
		                </uni-data-select>
		            </uni-forms-item>
		            <uni-forms-item name="bgValue" label="血糖值">
		                <uni-easyinput type="number" placeholder="请输入血糖值" v-model="formData.bgValue" ></uni-easyinput>
		            </uni-forms-item>
		            <uni-forms-item name="moodStatus" label="心情">
		                <uni-data-select placeholder="今天心情怎么样~~~~" v-model="formData.moodStatus" :localdata="formOptions.moodStatus">
		                </uni-data-select>
		            </uni-forms-item>
		            <uni-forms-item name="isTakeMedisinc" label="是否服药">
		                 <uni-data-select placeholder="吃药了吗~~~~" v-model="formData.isTakeMedisinc" :localdata="formOptions.isTakeMedisinc">
						 </uni-data-select>
		            </uni-forms-item>
		            <uni-forms-item name="food" label="食物">
		                <uni-easyinput type="textarea" autoHeight="true" placeholder="吃了哪些好吃的~~~" v-model="formData.food"></uni-easyinput>
		            </uni-forms-item>
		            <view class="uni-button-group">
		                <button type="primary" class="uni-button" @click="submit">提交</button>
		            </view>
		        </uni-forms>
	</view>
</template>

<script>
	import { getRandomInteger } from '../../utils/tools'
	export default {
		data() {
			return {
				 formData: {
					 "bgValue":0,
				 },
				            formOptions: {
				                bodyStatus: [{
				                    text: '随机',
				                    value:getRandomInteger(0,7),
				                }, {
				                    text: '空腹',
				                    value: 0,
				                }, {
				                    text: '早餐后',
				                    value: 1,
				                }, {
				                    text: '午餐前',
				                    value: 2
				                }, {
				                    text: '午餐后',
				                    value: 3
				                }, {
				                    text: '晚餐前',
				                    value: 4
				                }, {
				                    text: '晚餐后',
				                    value: 5
				                },
								{
								    text: '睡觉前',
								    value: 5
								},],
								
								moodStatus:[
									{
									    text: '心情一般',
									    value: 0,
									},
									{
									    text: '今天很高兴',
									    value: 1,
									},
									{
									    text: '糟糕得很',
									    value: 2,
									},
								],
								
								isTakeMedisinc:[
									{
										text:"吃药了",
										value:0,
									},
									{
										text:"没吃药",
										value:1,
									},
								],
								
				            },
				        }
		},
		methods: {
			getCreateTime(){
				this.formData['createTime'] = new Date().toLocaleString()
			}
			
		},
		onLoad() {
			this.intervalId = setInterval(()=>this.getCreateTime(),1000)
		},
		onUnload() {
			clearInterval(this.intervalId);
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		padding: 50rpx;
		
	}

</style>
